package com.lyz.dataStructure.map;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 9:39
 * @Description:
 **/

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/7/11 9:39
 *@Description:
 **/
public class HashMapDemo {
    public static void main(String[] args) {
        Map<Integer,String> map = new HashMap<Integer,String> ();

        map.put(1,"one");
        map.put(2,"two");
        map.put(3,"three");
        map.put(4,"four");
        map.put(5,"five");
        map.put(6,"six");
        map.put(7,"seven");
        map.put(8,"eight");
        map.put(5,"five");
        map.put(9,"nine");
        map.put(10,"ten");

        System.out.println(map.get(1));

        Iterator<Map.Entry<Integer,String>> it = map.entrySet().iterator();
        while (it.hasNext()){
            Map.Entry<Integer,String> entry = it.next();
            int key =entry.getKey();
            if(key%2==1){
                System.out.println(key+"="+key);
                it.remove();
            }
        }
        System.out.println("..................................");
        for(Map.Entry<Integer,String> entry:map.entrySet()){
            int k =entry.getKey();
            String v = entry.getValue();
            System.out.println(k+"="+v);
        }

    }
}
